package com.thinkgem.jeesite.modules.building.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.modules.building.dao.RoomDao;
import com.thinkgem.jeesite.modules.building.entity.Room;
import com.thinkgem.jeesite.modules.sys.utils.UserUtils;

@Service
@Transactional(readOnly = true)
public class RoomService extends CrudService<RoomDao,Room>{
	@Autowired
	RoomDao roomdao;
	/**
	 * 用用户ID找到房子
	 * */
	public Room findRoomByOwnerId(String ownerId){
		return roomdao.findRoomByOwnerId(ownerId);
	}
	/**
	 * 根据管理员的ID获得他所管理下的所有房子
	 * */
	public Page<Room> findMyAdminRoom(Page<Room> page,Room room){
		room.setPage(page);
		room.setId(UserUtils.getUser().getId());
		page.setList(roomdao.findMyAdminRoom(room));
		return page;
	}
	@Transactional(readOnly = false)
	public void deleteRoom(String id){
		roomdao.deleteRoom(id);
	}
	@Transactional(readOnly = false)
	public void deleteRoomByUserId(String id){
		roomdao.deleteRoomByUserId(id);
	}
	public List<Room> findRoomsByBuildingId(String id){
		return roomdao.findRoomsByBuildingId(id);
	}
}













